      *> File Name     000012_ValueVsRef.cbl.
      *> Description   Assigning value and reference types.
      *> Project Type  Console Application.
      *> CodePlex URL  http://cobol.codeplex.com
 
      *> Config        1. Add a reference to System.Drawing.
      *>
      *> Comments      Observe how assignment works differently for
      *>               value types as compared to reference types. Note
      *>               that .NET structs such as System.Drawing.Point
      *>               are value types. Classes are reference types.
 
       program-id.   Main.
       repository.
           class sys-console  as "System.Console"
           class sys-env      as "System.Environment"
           class class-point  as "Point"
           class struct-point as "System.Drawing.Point"
           .
       working-storage section.
       01  newline  string         value sys-env::"NewLine".
       01  ref1     class-point.
       01  ref2     class-point.
       01  val1     struct-point.
       01  val2     struct-point.
       procedure division.
           move "Assigning Value and Reference Types"
               to sys-console::"Title"
 
           move struct-point::"New"(0, 0) to val1
           move class-point::"New"(0, 0) to ref1
 
           move val1 to val2
           move ref1 to ref2
 
           invoke val2::"Offset"(10, 10)
           invoke ref2::"Offset"(10, 10)
 
           display "val1: " val1
           display "val2: " val2 newline
 
           display "ref1: " ref1
           display "ref2: " ref2 newline
 
           display "Press any key to continue . . . " no advancing
           invoke sys-console::"ReadKey"(true)
           .
       end program   Main.
 
       class-id.     Point.
       object.
       working-storage section.
       01  _x  binary-long.
       01  _y  binary-long.
      *>
       method-id.    New.
       linkage section.
       01  x  binary-long.
       01  y  binary-long.
       procedure division using by value x, y.
           move x to _x
           move y to _y
           .
       end method    New.
      *>
       method-id.    Offset.
       linkage section.
       01  dx  binary-long.
       01  dy  binary-long.
       procedure division using dx, dy.
           add dx to _x
           add dy to _y
           .
       end method    Offset.
      *>
       method-id.    get property X.
       procedure division giving n as binary-long.
           move _x to n.
       end method.
      *>
       method-id.    get property Y.
       procedure division giving n as binary-long.
           move _y to n.
       end method.
      *>
       method-id.    ToString override.
       local-storage section.
       01  fmt  string.
       procedure division giving s as string.
           move string::"Concat"("{X=", _x, ",Y=", _y, "}") to s.
       end method  ToString.
      *>
       end object.
       end class     Point.